import Http from "../Http";

export default {
    /**
     * 商品分类列表
     * @param data {{page:number,search:string}}
     * @returns {AxiosPromise}
     */
    lists(data = {}) {
        return Http.get("category", data)
    },

    /**
     * 获取所有分类
     * @returns {AxiosPromise}
     */
    all() {
        return Http.get("get_category")
    },

    /**
     * 删除分类
     * @param id {number}
     * @returns {AxiosPromise}
     */
    destroy(id) {
        return Http.post("category_delete", {id})
    },

    /**
     * 修改分类状态
     * @param id {number}
     * @returns {AxiosPromise}
     */
    toggleStatus(id) {
        return Http.post("category_status", {id})
    },

    create(data) {
        return Http.post("category_add", data);
    },

    update(data) {
        return Http.post("category_edit", data);
    },
}
